home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
cne
/
reslt1.exe
/
RESULTS.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1992-02-16
|
8KB
|
354 lines
PROGRAM CNEResults;
(* Show progress on Novell's CNE Assessment Test V2.0. *)
(* Input : CNE~RSP.DAT - Response file to the CNE assessment Test. *)
(* Output : RESULTS.RPT - An ASCII file which can be viewed or printed. *)
(* INPUT RECORD LOOKS LIKE THIS: *)
(* ┌───┬──────────┬───┬─────────┬─────┬───┬─────────┬───┬───────┬────────┬───────┬────────┐ *)
(* │0Ch│FIRST_NAME│20h│LAST_NAME│0007h│63h│TEST_NAME│63h│SEC_NUM│00h..00h│ANSWERS│20h..20h│ *)
(* └───┴──────────┴───┴─────────┴─────┴───┴─────────┴───┴───────┴────────┴───────┴────────┘ *)
(* VERSION HISTORY : *)
(* V1.00 2/16/92 - Initial version. Displays name, test, section, test results *)
(* (whether correct answer or choice was incorrect, and score. *)
(* Author : Eric J.G. Bonnell 73500,3250. *)
(* !!!!! NEXT Version Changes Go Here !!!!!!!!! *)
USES
Crt;
(* Standard I/O *)
CONST
NUL : Char = #$00;
Preamble : Char = #$0C;
Space : Char = #$20;
ResponseHeader : Char = #$07;
Letter_c : Char = #$63;
NessessaryCredits
= 'Compiled Using Turbo Pascal V6.0 (c) 1983,90 Borland International, Inc.';
VAR
InFile : Text;
(* CNE~RSP.DAT *)
OutFile : Text;
(* RESULTS.RPT *)
PROCEDURE Salutations;
(* Write an opening message on the screen. *)
BEGIN
WriteLn(ParamStr(0),' - CNE Assessment Test V2.0 Results.');
WriteLn(' V1.00 (c) 1992 Eric J.G. Bonnell 73500,3250.');
WriteLn(' May be altered, but must supply a new version number,');
WriteLn(' name, date and version history documentation!');
WriteLn
END (* Salutations *);
PROCEDURE Goodbyes;
(* Let user know it is done. *)
BEGIN
WriteLn('Finished. Results are recorded in RESULTS.RPT.');
WriteLn
END (* GoodByes *);
FUNCTION IsAlpha(C : Char) : Boolean;
(* True if C is alphabetic. *)
BEGIN
IsAlpha := C IN ['A'..'Z','a'..'z']
END (* IsAlpha *);
FUNCTION IsNumeric(C : Char) : Boolean;
(* True if C is a decimal digit. *)
BEGIN
IsNumeric:= C IN ['0'..'9']
END (* IsNumeric *);
FUNCTION IsPreamble(C : Char) : Boolean;
(* True if C is 0Ch. *)
BEGIN
IsPreamble:= C = Preamble
END (* IsPreamble *);
FUNCTION IsSpace(C : Char) : Boolean;
(* True if C is 20h. *)
BEGIN
IsSpace := C = Space
END (* IsSpace *);
FUNCTION IsNul(C : Char) : Boolean;
(* True if C is 00h. *)
BEGIN
IsNul := C = NUL
END (* IsNul *);
FUNCTION IsCntrl(C : Char) : Boolean;
(* True if C is not alphanumeric (not nessessarily a control character). *)
BEGIN
IsCntrl := NOT IsAlpha(C) AND NOT IsNumeric(C)
END (* IsCntrl *);
FUNCTION IsResponseHeader(C : Char) : Boolean;
(* True if C iss 07h. *)
BEGIN
IsResponseHeader := C = ResponseHeader
END (* IsResponseHeader *);
FUNCTION IsLetter_c(C : Char) : Boolean;
(* True if C is a lowercase letter 'c'. *)
BEGIN
IsLetter_c := C = Letter_c
END (* IsLetter_c *);
FUNCTION UpperCase(S : String) : String;
(* Convert S to all upper case characters. *)
VAR
I : 0..255;
BEGIN
I := Length(S);
WHILE I > 0 DO
BEGIN
S[I] := UpCase(S[I]);
Dec(I)
END;
UpperCase := S
END (* UpperCase *);
FUNCTION NoMore(VAR F : Text) : Boolean;
(* True if end-of-file found, otherwise found next record. *)
VAR
C : Char;
BEGIN
C := #$FF;
REPEAT
Read(F,C);
NoMore := EoF(F)
UNTIL IsPreamble(C) OR EoF(F)
END (* NoMore *);
PROCEDURE OpenFiles(VAR F,
O : Text);
(* Open input and output files. *)
BEGIN
Assign(F,'CNE~RSP.DAT');
ReSet(F);
Assign(O,'RESULTS.RPT');
ReWrite(O)
END (* OpenFiles *);
PROCEDURE CloseFiles(VAR F,
O : Text);
(* Close input and output files. *)
BEGIN
Close(F);
Close(O)
END (* CloseFiles *);
FUNCTION FirstName(VAR F : Text) : String;
(* Retrieve FIRST_NAME from current record in file F. *)
VAR
S : String;
C : Char;
BEGIN
S := '';
C := #$00;
WHILE (NOT EoF(F)) AND (NOT IsSpace(C)) DO
BEGIN
Read(F,C);
S[0] := Chr(Ord(S[0]) + 1);
S[Ord(S[0])] := C
END;
FirstName := UpperCase(S)
END (* FirstName *);
FUNCTION LastName(VAR F : Text) : String;
(* Retrieve LAST_NAME from current record in file F. *)
VAR
S : String;
C : Char;
BEGIN
S := '';
C := #$FF;
Read(F,C);
WHILE (NOT EoF(F)) AND IsAlpha(C) DO
BEGIN
S[0] := Chr(Ord(S[0]) + 1);
S[Ord(S[0])] := C;
Read(F,C)
END;
LastName := UpperCase(S)
END (* LastName *);
FUNCTION TestName(VAR F : Text) : String;
(* Retrieve TEST_NAME from current record in file F. *)
VAR
S : String;
C : Char;
BEGIN
S := '';
C := #$00;
Read(F,C);
WHILE (NOT Eof(F)) AND IsResponseHeader(C) DO
Read(F,C);
Read(F,C);
WHILE (NOT EoF(F)) AND (NOT IsLetter_c(C)) DO
BEGIN
S[0] := Chr(Ord(S[0]) + 1);
S[Ord(S[0])] := C;
Read(F,C)
END;
TestName := UpperCase(S)
END (* TestName *);
FUNCTION SectionNumber(VAR F : Text) : Integer;
(* Retrieve SEC_NUM from current record in file F. *)
VAR
Code : Integer;
Value : Integer;
S : String;
C : Char;
BEGIN
S := '';
C := #$00;
WHILE (NOT Eof(F)) AND IsResponseHeader(C) DO
Read(F,C);
Read(F,C);
FOR Code := 1 TO 2 DO
BEGIN
S[0] := Chr(Ord(S[0]) + 1);
S[Ord(S[0])] := C;
Read(F,C)
END;
Val(S,Value,Code);
SectionNumber := Value
END (* SectionNumber *);
FUNCTION QuestionStatus(VAR F : Text;
VAR Q : Integer;
VAR I : Integer;
VAR N : Integer;
VAR C : Char) : String;
(* Determine the results of Question Q in current record in F.
tally I correct responces for N total questions, passing back
the next field C in record. *)
VAR
S : String;
T : String;
BEGIN
S := '';
Str(Q,S);
IF Length(S) < 2 THEN
S := ' ' + S;
T[0] := Chr(1);
T[1] := C;
T := UpperCase(T);
Inc(N);
IF IsNumeric(C) THEN
BEGIN
Inc(I);
QuestionStatus := 'Question ' + S + ' was answered correctly.'
END
ELSE
QuestionStatus := 'Question ' + S + ' was incorrectly answered! [' + T + ']';
Inc(Q);
Read(F,C)
END (* QuestionStatus *);
PROCEDURE ListEm(VAR F : Text;
VAR O : Text;
VAR I : Integer;
VAR N : Integer);
(* Step through all the responses until there are no more in F.
Write a status for the response in O and tally I correct responses
for N total questions. *)
VAR
C : Char;
Q : Integer;
Waste : 0..10;
BEGIN
Q := 1;
C := #$FF;
C := #$FF;
FOR Waste := 1 TO 10 DO
Read(F,C);
WHILE (NOT EoF(F)) AND (NOT IsSpace(C)) DO
WriteLn(O,QuestionStatus(F,Q,I,N,C))
END (* ListEm *);
PROCEDURE DoIt(VAR F,
O : Text);
(* List out the information in file F into ASCII text output file O. *)
VAR
Percentage : Real;
I : Integer;
N : Integer;
BEGIN
WriteLn(O,'────────────── CNE Assessment Test Results ───────────────');
WHILE NOT NoMore(F) DO
BEGIN
Percentage := 0.0;
I := 0;
N := 0;
WriteLn(O);
WriteLn(O,'TESTED : ',FirstName(F),' ',LastName(F),'.');
WriteLn(O);
WriteLn(O,'COURSE : ',TestName(F),' SECTION : ',SectionNumber(F));
WriteLn(O);
ListEm(F,O,I,N);
Percentage := I / N * 100;
WriteLn(O);
WriteLn(O);
WriteLn(O,'SCORE : ',I,' Correct out of ',N,' = ',Percentage:5:2,'%.');
WriteLn(O);
WriteLn(O,'──────────────────────────────────────────────────────────')
END
END (* DoIt *);
BEGIN (* main *)
Salutations;
OpenFiles(InFile,OutFile);
DoIt(InFile,OutFile);
CloseFiles(InFile,OutFile);
Goodbyes
END.